package org.ns.longhttp.config;

import org.ns.longhttp.BeanUtil;
import org.ns.longhttp.handler.asynchandler.DefaultUrlEventQueue;
import org.ns.longhttp.selector.datamapper.DefaultDataMappingEntry;
import org.ns.longhttp.selector.datamapper.responseid.DefaultDataResponseIdFactory;
import org.ns.longhttp.verify.NotEmpty;
import org.ns.longhttp.verify.NotZore;

/**
 * 服务配置
 */
public class ServerConfig {

    public static ServerConfig DEFAULT_CONFIG = new ServerConfig();

    private String dataQueueEntryClassname = DefaultDataMappingEntry.class.getName();
    private String dataIdFactoryClassname = DefaultDataResponseIdFactory.class.getName();
    private String urlEventQueueClassname = DefaultUrlEventQueue.class.getName();

    private int dataQueueClearThreadSize = 5; // 数据队列清理线程数
    private int asyncResponseThreadSize = 5; // 异步应答处理线程数
    private int requestClearThreadSize = 5; // 请求超时清理线程数

    public @NotEmpty String getDataQueueEntryClassname() {
        return dataQueueEntryClassname;
    }

    public void setDataQueueEntryClassname(@NotEmpty String dataQueueEntryClassname) {
        BeanUtil.throwNullException(dataQueueEntryClassname, "dataQueueEntryClassname");
        this.dataQueueEntryClassname = dataQueueEntryClassname;
    }

    public @NotEmpty String getDataIdFactoryClassname() {
        return dataIdFactoryClassname;
    }

    public void setDataIdFactoryClassname(@NotEmpty String dataIdFactoryClassname) {
        BeanUtil.throwNullException(dataIdFactoryClassname, "dataIdFactoryClassname");
        this.dataIdFactoryClassname = dataIdFactoryClassname;
    }

    public @NotEmpty String getUrlEventQueueClassname() {
        return urlEventQueueClassname;
    }

    public void setUrlEventQueueClassname(@NotEmpty String urlEventQueueClassname) {
        BeanUtil.throwNullException(urlEventQueueClassname, "urlEventQueueClassname");
        this.urlEventQueueClassname = urlEventQueueClassname;
    }

    public @NotZore int getDataQueueClearThreadSize() {
        return dataQueueClearThreadSize;
    }

    public void setDataQueueClearThreadSize(@NotZore int dataQueueClearThreadSize) {
        BeanUtil.throwZoreException(dataQueueClearThreadSize, "dataQueueClearThreadSize");
        this.dataQueueClearThreadSize = dataQueueClearThreadSize;
    }

    public @NotZore int getAsyncResponseThreadSize() {
        return asyncResponseThreadSize;
    }

    public void setAsyncResponseThreadSize(@NotZore int asyncResponseThreadSize) {
        BeanUtil.throwZoreException(asyncResponseThreadSize, "asyncResponseThreadSize");
        this.asyncResponseThreadSize = asyncResponseThreadSize;
    }

    public @NotZore int getRequestClearThreadSize() {
        return requestClearThreadSize;
    }

    public void setRequestClearThreadSize(@NotZore int requestClearThreadSize) {
        BeanUtil.throwZoreException(requestClearThreadSize, "requestClearThreadSize");
        this.requestClearThreadSize = requestClearThreadSize;
    }
}
